package reflect;

import java.lang.reflect.Method;

/**
 * 反射机制使用注解
 */
public class ReflectDemo7 {
    private String test;
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class cls = Class.forName("reflect.Person");
//        Class cls = Class.forName("reflect.ReflectDemo7");
        /*boolean isAnnotationPresent(Class cls)
            该方法在类对象Class,方法对象Method等常用的反射对象上都有定义.
            作用是判断是否被参数cls表示的注解标注了.*/
        boolean mark = cls.isAnnotationPresent(AutoRunClass.class);
        Method method = cls.getMethod("main", String[].class);
        boolean mark1 = method.isAnnotationPresent(AutoRunClass.class);

        System.out.println("是否被注解:"+mark1);
    }
}
